home *** CD-ROM | disk | FTP | other *** search
- # SpecTcl, by S. A. Uhler
- # Copyright (c) 1994-1995 Sun Microsystems, Inc.
- #
- # See the file "license.txt" for information on usage and redistribution
- # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- #
- # This file contains misc. routines that probably belong somewhere else
-
- # update the scroll region of a frame's containing canvas
- # This should be called every time the frame changes size
- # there should be a separate one of these for forms
-
- if {$P(center)} {
- proc scrollregion_update {frame} {
- set canvas [winfo parent $frame]
- set fw [winfo reqwidth $frame ]
- set fh [winfo reqheight $frame]
- set cw [winfo width $canvas]
- set ch [winfo height $canvas]
-
- set x1 [expr ($fw - $cw)/2]
- set x2 [expr $x1 + $cw]
- set y1 [expr ($fh - $ch)/2]
- set y2 [expr $y1 + $ch]
- foreach i "$canvas ${canvas}_row ${canvas}_column" {
- catch {$i configure -scrollregion "$x1 $y1 $x2 $y2"}
- }
- }
- } else {
- proc scrollregion_update {frame} {
- set canvas [winfo parent $frame]
- set width [winfo reqwidth $frame ]
- set height [winfo reqheight $frame]
- foreach i "$canvas ${canvas}_row ${canvas}_column" {
- catch {$i configure -scrollregion "0 0 $width $height"}
- }
- }
- }
-
- # update table geometry
- # This should be call anytime the geometry of the table changes
- # Its slow, so try not to do this too often
- # parent: The "master" of the widgets
-
- # Schedule an update to happen later
-
- proc update_table {master {why "?"}} {
- global Update_Scheduled
- if {![info exists Update_Scheduled]} {
- dputs $master
- after idle "do_update_table"
- }
- dputs $master ($why)
- set Update_Scheduled($master) 1
- }
-
- # do all scheduled updates
-
- proc do_update_table {} {
- global Update_Scheduled
- # outline_forget
- set list [array names Update_Scheduled]
- dputs <$list>
- foreach master $list {
- table_setup $master
- arrow_update .can $master
- outline_update $master
- }
- scrollregion_update .can.f
- catch {unset Update_Scheduled}
- }
-
- # run a command later, but not if already scheduled
-
- proc when_idle {cmd {when idle}} {
- after cancel $cmd
- after $when $cmd
- }
-
- # update the b-search routines
- # master: The list of masters to update
- # obsolete
-
- proc update_bsearch {master} {
- dputs "Bsearch: $master"
- foreach i $master {
- upvar #0 geom:$i data
- eval [gen_bsearch get_col_$i $data(column_coords) -1]
- eval [gen_bsearch get_row_$i $data(row_coords) -1]
- }
- }
-
- # clone a widget for interactive placement (just geometry)
-
- proc clone_widget {old new} {
- lappend cmd [string tolower [winfo class $old]] $new
- foreach option [$old configure] {
- if {[llength $option] != 5} continue
- if {[string compare [lindex $option 3] [lindex $option 4]] ==0} continue
- lappend cmd [lindex $option 0] [lindex $option 4]
- }
- catch "destroy $new"
- dputs $old -> $new
- eval $cmd
- }
-
- # just a little !PC
-
- proc choose_insult {} {
- set insults {
- dummy moron idiot numbskull dweeb twit sped geek nerd
- }
- return [lindex $insults [expr [info cmdcount] % [llength $insults]]]
- }
-
- # unselect the current widget, removing the option box if any
- # might as well get rid of the resize-handles, if any, and extra outline box
-
- proc unselect_widget {} {
- global Current Geometry
- if {[set current $Current(widget)] != ""} {
- dputs $current
- set Current(widget) {}
- set Current(form) {}
- set Current(text) {}
- if {[winfo ismapped .widget]} {
- set Geometry(widget) [wm geometry .widget]
- wm withdraw .widget
- }
- # this doesn't belong here!
- .entry configure -state disabled
- # undo the highlighting
- set name [winfo name $current]
- window_unhighlight $current
- # this will remove a superfluous outline
- global $name
- outline_trace $name
- del_resize_handles ${current}_outline
- }
- }
-
- # make an option entry form, make it tough to destroy
- # this will be expanded later. Make sure its OK for the user to destroy
- # The window
-
- proc build_option_form {form {event 0}} {
- if {$event} {
- global Current
- window_unhighlight $Current(sample) palette
- set Current(sample) {}
- }
- if {[winfo exists $form]} {
- bind $form <Destroy> {}
- destroy $form
- }
- toplevel $form
- label $form.msg -width 40
- frame $form.form -highlightthickness 0
- blt_table $form $form.form 0,0 -fill both
- blt_table $form $form.msg 1,0 -fill none
- blt_table row $form configure 0 -resize both
- blt_table row $form configure 1 -resize none
- blt_table column $form configure 0 -resize both
- wm withdraw $form
- bind $form <Destroy> {
- if {[winfo class %W] == "Toplevel" } {
- after idle "build_option_form %W 1"
- }
- }
- }
-
- # don't put the following items into forms
- # this doesn't really belong here
-
- proc ignore_items {} {
- global Widget_data
- array set Widget_data {
- ignore:type {}
- ignore:pathname {}
- ignore:error {}
- ignore:focus {}
- ignore:level {}
- ignore:master {}
- ignore:resize_row {}
- ignore:resize_column {}
- ignore:min_row {}
- ignore:min_column {}
- ignore:reqwidth {}
- ignore:reqheight {}
- }
- }
-
- # update the current form (if any) given a new widget value
- # This belongs in the forms package.
-
- proc sync_form {field value} {
- global Widget_data _Message Current
-
- dputs $field $value
- if {[set win $Current(widget)] == ""} {return 0}
- set Current(dirty) 1
- upvar #0 [winfo name $win] data
- if {[info exists data($field)]} {
- set data($field) $value
- dputs "Setting [winfo name $win] $field <- $value"
- }
-
- # update the entry form (if it exists)
-
- set entry .widget.form.can.f.[winfo name $win],${field},entry
- dputs "updating $entry ($field := $value)"
- if {$Current(form) == $win && [winfo exists $entry]} {
- if {[info exists Widget_data(infilter:$field)]} {
- if {![$Widget_data(infilter:$field) value]} {
- set _Message $value
- return 0
- }
- }
- $entry delete 0 end
- $entry insert 0 $value
- }
- return 1
- }
-
- # keyboard short cuts for text entry - just testing
- # Automatically select a different widget
- # - If no widget is selected, select 1st widget in current frame
- # - If a widget is selected, select next widget in current frame
-
- proc short_cut {what} {
- global Current Widgets
- set widget $Current(widget)
- upvar #0 geom:$Current(frame) data
-
- set widgets [blt_table slaves $Current(frame) -match *#* -exclude *@*]
- dputs $widgets
- if {[llength $widgets] < 1 } return
- if {[llength $widgets] < 2 && $Current(widget) != ""} return
- switch -glob $what {
- *Right {set opt increasing}
- *Left {set opt decreasing}
- }
- set sorted [lsort -$opt -command "sort_widgets" $widgets]
- dputs $sorted
-
- # loop through list to next widget which isn't me
-
- set me 0
- foreach i "$sorted [lindex $sorted 0]" {
- if {$widget != $i} {
- if {$me} break continue ;# I couldn't resist
- } else {incr me}
- }
- unselect_widget
- select_widget $i
- focus .entry
- update idletasks
- }
-
- # sort some widgets either by increasing rows or columns
- # we should cache this information
-
- proc sort_widgets {win1 win2} {
- scan [blt_table info $win1] "%*s %d,%d" r1 c1
- scan [blt_table info $win2] "%*s %d,%d" r2 c2
- #puts "$r1,$c1 $r2,$c2"
- return [expr {($r1*1000 + $c1) - ($r2*1000 + $c2)}]
- }
-
- # save, compile and run!
- # save to a different file name, and preserve the dirty bit
- # the file management is poor, and needs fixing
-
- set Current(Test_app) ""
- proc build_app {name {wish wish4.1}} {
- global _Message Widgets Current P
- if {![info exists Widgets]} {
- set _Message "Nothing to build"
- return
- }
-
- # compute frame stacking and tabbing order
- global f; set f(level) 0
- set_frame_level .can.f
-
- set dirty $Current(dirty)
- set name [file root $Current(project)]
- set file STest[pid]
- save_project $file.ui
- exec touch $file.ui
- compile $file.ui $file.ui.tcl $name
- set _Message "Starting test application"
- set Current(project) $name
- set Current(dirty) $dirty
- set_title $name
- update idletasks
-
- set tmp /tmp/ST[pid].tcl
- set fd [open $tmp w]
- set Current(test_app) test_$name
- puts $fd "tk appname \"test_$name\""
- puts $fd "wm title . \"SpecTcl - $name\""
- puts $fd "source \"[pwd]/$file.ui.tcl\""
- if {[file readable $name.tcl]} {
- puts $fd "source \"[pwd]/$name.tcl\""
- } else {
- puts $fd "\"${name}_ui\" ."
- }
- close $fd
- catch {send test_$name "after 1 {exit 0}"}
- exec $wish $tmp &
-
- # we should remove the temp files carefully
-
- after 2000 "exec rm -f $file.ui.tcl $file.ui"
- }
-
- # remove all outline traces - reset application
-
- proc reset_outlines {{name {}}} {
- global Widgets Current
- if {$name == "" && [array exists Widgets]} {
- set list [array names Widgets]
- } else {
- set list $name
- }
- foreach i $list {
- trace vdelete ${i}(geometry:rowspan) w outline_trace
- trace vdelete ${i}(geometry:columnspan) w outline_trace
- }
- }
-
- ######## Stuff added to support row/column indicators
-
- # scroll multiple canvii with a single scroll bar
- # list: The list of canvii to scroll
- # how: "x" or "y"
- # args: The rest
-
- proc can_view {list how args} {
- foreach canvas $list {
- eval "$canvas ${how}view $args"
- }
- }
-
- # extract info about a row or column of the table geometry manager
- # There's no easy way
- # master: The table "master"
- # type: "row" or "column"
- # index: the column or row number
- # array: Where to place the results
-
- proc extract_geom {master type index array} {
- upvar $array data
- set config [blt_table $type $master configure $index]
- set data(pad) [lindex [lindex $config 0] 4]
- set data(resize) [lindex [lindex $config 1] 4]
- set dim [lindex [lindex $config 2] 4]
- set data(min) [lindex $dim 0]
- set data(max) [lindex $dim 1]
- return ""
- }
-
- # put it back
-
- proc insert_geom {master type index array} {
- global P
- upvar $array data
-
- if {$data(min) < $P(grid_size)} {
- set min $P(grid_size)
- } else {
- set min $data(min)
- }
-
- blt_table $type $master configure $index \
- -padx $data(pad) \
- -resize $data(resize) \
- -width "$min $data(max)"
- }
-
- # this is just a place holder for now - should be a menu
- # this should be obsolete
-
- proc next_text_style {win} {
- global Current _Message
- set styles {"" Bold Italic Bold,Italic}
- if {[set widget $Current(widget)] == ""} {return}
-
- # extract the font components from the widget
- if {[catch {set font [$widget cget -font]}]} {
- set _Message "Font style not available for [winfo class $widget]"
- return
- }
- InFilter_font font
- regexp {([^,]*,[^,]*),*(.*)} $font dummy base style
-
- # go to next style
-
- set current [lsearch $styles $style]
- if {[incr current] >= [llength $styles]} {set current 0}
- set font $base,[lindex $styles $current]
-
- # convert and set back new style
-
- if {![OutFilter_font dummy font font]} {
- set _Message $font
- return
- }
- catch "$widget configure -font $font"
-
- # now update the style of the template
-
- set font [$win cget -font]
- InFilter_font font
- regexp {([^,]*,[^,]*),*(.*)} $font dummy base style
- set font $base,[lindex $styles $current]
- OutFilter_font dummy font font
- sync_form font $font
- catch "$win configure -font $font"
- }
-
- # choose the next text-style for the current widget
-
- set Fontstyle ""
- proc setup_style {win name {command puts}} {
- global Fontstyle
- menubutton $win -menu $win.style -width 2 \
- -textvariable $name -bd 2 -relief ridge -padx 1 -pady 1
- menu $win.style
- set font [$win.style cget -font]
- InFilter_font font
- regexp {([^,]*,[^,]*),*(.*)} $font dummy base style
- foreach style {"" Bold Italic Bold,Italic} {
- set font $base,$style
- OutFilter_font dummy font font
- $win.style add command -label A -font $font -command "
- set $name $style
- eval \"$command $item\"
- "
- }
- }
-
- # Delete whatever is currently selected
-
- proc delete_selected {{arrows 1}} {
- global Current _Message
- undo_mark
- if {[set die $Current(widget)] != ""} {
- delete_selected_widget $die
- } elseif {$arrows} { ;# try to delete selected row or column
- delete_selected_arrow
- }
- update_table .can.f delete_widget
- }
-
- # delete the currently selected widget
-
- proc delete_selected_widget {die} {
- global Current _Message Widgets Frames P
-
- unselect_widget
- set name [winfo name $die]
- reset_outlines $name
- catch "destroy ${die}_outline"
-
- # destroy all widgets packed inside
-
- if {[info exists Frames($die)]} {
- undo_log delete_frame [winfo name $die] [grid_size $die]
- grid_destroy $die ;# only needed if we don't destroy the widget
- foreach i [blt_table slaves $die] {
- delete_selected_widget $i
- }
- unset Frames($die)
- } else {
- undo_log delete_widget $name
- }
-
- # blt_table forget $die ;# redundant with destroy
- destroy $die
- unset Widgets($name)
- # reset grid spacing if row/col becomes empty
- grid_spacing $Current(frame) ;# lazy!
- set Current(widget) {}
- }
-
- # delete the currently selected row and/or column BROKEN!
-
- proc delete_selected_arrow {} {
- global Current _Message
- foreach i {row column} {
- if {[set tag $Current($i)] != ""} {
- regexp {tag:([^_]*)_(.*)} $tag dummy master index
- dputs "creating arrow $master $i $index"
- if {![table_delete $master $i $index]} {
- set _Message "can't delete non-empty $i"
- } elseif {[grid_remove $master $i]} {
- grid_update $master
- set tag [arrow_delete .can $i $master]
- if {$Current($i) == $tag} {
- dputs "Unselecting dead $i arrow $tag"
- set Current($i) ""
- }
- }
- }
- }
- }
-
- # display progress of widget initialization
-
- proc widget_progress {name} {
- global _Message
- set _Message "locating all widgets: $name"
- update idletasks
- }
-
- # temporary test mode (broken)
-
- proc test_mode {} {
- global P _Message Test_mode Grid Was_grid
- if {$Test_mode} {
- set _Message "entering test mode"
- unselect_widget
- button_undo widget $P(button)
- button_undo sub_widget $P(button)
- set Was_grid 0
- if {$Grid != 0} {
- .buttons.grid invoke
- set Was_grid 1
- }
- grid_spacing .can.f 0
- } else {
- set _Message "entering edit mode"
- grid_spacing .can.f $P(grid_spacing)
- button_setup . widget widget $P(button) $P(gravity)
- if {$Was_grid} {
- .buttons.grid invoke
- }
- # for sub-frames
- button_setup . sub_widget widget $P(button) $P(gravity) \
- {[winfo parent %W] %X %Y}
- }
- }
-
- # place holder
-
- proc frame_configure {win} {
- dputs "Calling frame configure"
- }
-
-
- # choose black, except when it won't show, then white
-
- proc contrast_color {color} {
- set rgb [winfo rgb . $color]
- set y [expr {
- [lindex $rgb 0]*0.6 + [lindex $rgb 1]*0.3 + [lindex $rgb 2]*0.1
- }]
- return [expr {$y > 1000 ? "black" : "white"}]
- }
- # choose black, except when it won't show, then white
-
- proc Contrast_color {color} {
- set result #
- foreach i [winfo rgb . $color] {
- if {$i > 32768 } {append result 0} {append result F}
- }
- return $result
- }
-
- proc current_frame {frame} {
- global Frames Current P
- dputs $frame ? $Current(frame)
- if {$frame == $Current(frame)} return
- set Current(frame) $frame
- # do_update_table $frame switch-frame ;# doesn't belong here!
- arrow_unhighlight row
- arrow_unhighlight column
- arrow_activate .can $frame ;# temporary?
-
- # fix up the grid colors
-
- foreach i [array names Frames] {
- set current [$i cget -bg]
- if {$i == $frame} {
- grid_color $i [Contrast_color $current]
- } else {
- grid_color $i $current
- }
- }
- }
-
- # We'll keep track of this our selves
-
- proc find_master {win} {
- upvar #0 [winfo name $win] data
- return $data(master)
- }
-
- # set the master window for this widget
- # We'll keep it in the widgets configuration array
- # widget: The widget name
- # master: The frame its packed in
-
- proc set_master {widget master} {
- upvar #0 [winfo name $widget] data
- dputs "set_master: $widget $master"
- regsub {^\.can\.f} $master {} data(master)
- }
-
- # compute the nesting depth of frames, so their stacking order is
- # generated correctly. Store result in the "level" entry of the widget
- # structure
-
- proc set_frame_level {master {level 0}} {
- incr level
- set exclude "@"
- regexp {frame#[0-9]+} $master exclude
- dputs "setting level $level for $master (exclude $exclude)"
- foreach frame [blt_table slaves $master -exclude *${exclude}* -match *frame#*] {
- upvar #0 [winfo name $frame] data
- set data(level) $level
- set_frame_level $frame $level
- dputs "level: $frame = $level"
- }
- }
-
- # compute a widgets nominal position, which is the top left corner
- # of its enclosing cell
-
- proc get_tabbing_coords {win} {
- upvar #0 [winfo name $win] data
- upvar #0 geom:.can.f$data(master) geom
- scan [blt_table info $win] "%s %d,%d" dummy row col
- set x [expr [winfo x .can.f$data(master)] + $geom(column_$col)]
- set y [expr [winfo y .can.f$data(master)] + $geom(row_$row)]
- dputs "$win: (master $data(master)) $row,$col -> $x,$y"
- return "$y $x"
- }
-
- # figure out which sub-grid we're sitting on
- # x,y: Where we're at (%X, %Y)
- # skip: never decend into this level
- # start: where in the grid to start (used internally to manage recursion)
-
- proc find_grid {x y {skip ""} {start ".can.f"}} {
- global Frames
-
- # don't desend onto self
-
- if {$start == $skip} {
- dputs "Skipping SELF $start"
- return $start
- }
-
- upvar #0 geom:$start data
- set row [blt_table row $start location "$y - [winfo rooty $start]"]
- set column [blt_table column $start location "$x - [winfo rootx $start]"]
- set owner [blt_table slaves $start -column $column -row $row]
- if {[info exists Frames($owner)]} {
- set start [find_grid $x $y $skip $owner]
- }
- return $start
- }
-
- # describe a widget briefly
-
- proc widget_describe {win} {
- upvar #0 [winfo name $win] data
-
- set text "?"
- set class $data(type)
- if {[info exists data(text)]} {
- set text $data(text)
- } elseif {[info exists data(label)]} {
- set text $data(label)
- } else {
- set text $data(item_name)
- set try [split $text #]
- if {[llength $try] > 1} {
- set text [lindex $try end]
- }
- }
- regsub -all "\n" $text / text
- set text [string range $text 0 [string length $class]]
- if {$text == $class} {
- return $class
- } else {
- return "$class\n$text"
- }
- }
-
- # see if a configuration change to a widget requires a table update
- # name: The name of the window that got a configure event
- # This still forces updates even when none are needed
-
- proc check_update {name} {
- upvar #0 [winfo name $name] data
- set need_update 0
- set width [winfo width $name]
- set height [winfo height $name]
- if {[catch {set change [expr $width != $data(pixel_width) || \
- $height != $data(pixel_height)]}] || $change} {
- set data(pixel_width) $width
- set data(pixel_height) $height
- update_table .can.f$data(master) "configure $data(master) $name"
- }
- }
-
- # A simpler version
-
- proc check_update {name} {
- upvar #0 [winfo name $name] data
- update_table .can.f$data(master) "configure$name"
- }
-
- # adjust the resize behavior of the row or col if its the first one
- # add in the widget, making sure to get the resize behavior right
- # master: the table to adjust
- # widget: The widget I'm about to add
- # row,col: Where its about to go
-
- proc table_enter {master widget row col} {
- global P
- upvar #0 geom:$master data
- blt_table $master $widget $row,$col
- }
-
- # This is an experiment to use the window to be moved as its cursor!
-
- # grab an image of a window, to turn into a cursor
-
- proc make_cursor_from_window {{win .}} {
- set file /tmp/$win.[pid]
- set dither mdither
- set data [exec xgrabsc -id [winfo id $win] -nobell -noborders -$dither -bm]
- regsub {x_hot 0} $data "x_hot [expr [winfo width $win]/2]" data
- regsub {y_hot 0} $data "y_hot [expr [winfo height $win]/2]" data
- set fd [open $file w]
- dputs $fd $data
- close $fd
- return $file
- }
-
- # set the cursor to look like the window its on!
-
- proc set_cursor {win {color black}} {
- global Cursor_save
- set Cursor_save($win) [$win cget -cursor]
- dputs "SAVING $win"
- $win configure -cursor watch
- update idletasks
- $win configure -cursor "@[make_cursor_from_window $win] $color"
- }
-
- proc unset_cursor {} {
- global Cursor_save
- parray Cursor_save
- set win [array names Cursor_save]
- $win configure -cursor $Cursor_save($win)
- unset Cursor_save
- after idle "exec rm -f /tmp/$win.[pid]"
- }
-
- # extract/insert blt_table options into an array
- # convert row and column to behave!
-
- proc blt_get {win array} {
- upvar $array data
- array set data [blt_table info $win]
- set tmp [split $data($win) ,]
- array set data "-row [lindex $tmp 0] -column [lindex $tmp 1]"
- unset data($win)
- unset data(-reqheight) data(-reqwidth) ;# we don't use these for now
- }
-
- proc blt_set {table win array} {
- upvar $array data
- set geom $data(-row),$data(-column)
- unset data(-row) data(-column)
- return "blt_table $table $win $geom [array get data -*]"
- }
-
- # snagged from the net
-
- set RNseed [pid]
- proc random {} {
- global RNseed
- set RNseed [expr 30903*($RNseed&65535)+($RNseed>>16)]
- return [expr ($RNseed & 65535)/65535.0]
- }
-
- # insert a binding tag into a window
-
- proc insert_tag {win tag} {
- set tags [bindtags $win]
- if {[lsearch -exact $tags $tag] != -1} {
- return 0 ;# tag is already there
- }
- bindtags $win "$tag $tags"
- return 1
- }
-
- # delete a tag from a tag binding.
-
- proc delete_tag {win tag} {
- set tags [bindtags $win]
- if {[set index [lsearch -exact $tags $tag]] == -1} {
- return 0 ;# tag is not there
- } else {
- bindtags $win [lreplace $tags $index $index]
- }
- return 1
- }
-
- # temporary procedure to edit code
-
- set Clip ""
- proc edit_code {{name untitled}} {
- catch "destroy .edit"
- toplevel .edit
- wm title .edit "$name Code"
- edit_ui .edit
- }
-
-
- # clear out everyhing (less drastic than reset)
-
- proc clear_all {{restart 1}} {
- global Widgets Current Frames Next_widget argv P f
-
- # pop up dialog if dirty bit is set
- if {$Current(dirty) != ""} {
- set msg "$Current(project) has not been saved"
- switch [tk_dialog .sure Warning $msg "questhead" \
- 0 Cancel "Save $Current(project)" "Discard changes"] {
- 0 {return 0}
- 1 {save_project $Current(project).$P(file_suffix) 1}
- }
- }
- set Current(dirty) ""
-
- foreach i [array names Widgets] {
- global $i
- catch "unset $i"
- }
- set argv ""
- catch {unset Frames}
- catch {unset Undo_log}
- undo_reset
- eval "destroy [winfo children .can.f] .widget .generic"
- arrow_zapall .can
- foreach i [array names Next_widget] {
- set Next_widget($i) 0
- }
- foreach i [array names Current] {
- set Current($i) ""
- }
- catch {unset Widgets}
- catch {unset f}
-
- if {!$restart} return
-
- # reinitilize main
- # This is overkill, but play it safe for now
-
- set parent .can.f
- frame $parent.marker ;# stacking order marker - below all buttons
- set Current(frame) $parent
- set Current(project) $P(project)
- set_title $Current(project)
- set Frames($parent) 1
- current_frame $parent
-
- widget_extract .can.f
- set_master .can.f .can.f
- set f(type) frame
- grid_create .can.f $P(maxrows) $P(maxcols) $P(grid_size) $P(grid_color)
- table_setup $parent
- arrow_zapall .can
- arrow_create .can_row row .can.f all
- arrow_create .can_column column .can.f all
- arrow_activate .can $parent $P(grid_color)
- return 1
- }
-
- # short cut for accessing fields in property sheet (temporary)
- # look for fields of the form: .widget.form.can.f.<widget>,key*,entry
- # If a field is in the map, go to it, else go to the 1st with letter
-
- array set Access_map {
- t textvariable
- c command
- v variable
- i item_name
- w width
- }
-
- # wrong! need to check config array instead!
- # short cut for popping up option sheets. Call the tk menu traversal
- # code explicitly if the key is not relevent
-
- proc access_field {key} {
- global Current _Message Access_map
- if {[set win $Current(widget)] == ""} {
- return 0
- }
-
- catch {set key $Access_map($key)}
- upvar #0 [winfo name $win] data
- set field [lindex [lsort [array names data $key*]] 0]
- dputs "accessing <$key> ($field)"
- if {$field == ""} {
- return 0
- }
- eval widget_up $win 0 0 .widget.form.can.f.[winfo name $win],$field,entry
- raise .widget
- return 1
- }
-
- # Quit with dialog
-
- proc quit {{cancel 1}} {
- if {![catch {glob /tmp/*[pid].tcl} result]} {
- eval exec "rm -f $result" ;# need to put somewhere
- }
- set buttons {really\nquit "Save\n& quit"}
- if {$cancel} {
- lappend buttons Cancel\n
- }
- global Current P
- if {$Current(dirty) == ""} exit
- set message "There are unsaved changes\nare you sure?"
- switch [eval tk_dialog .quit quit \$message questhead 0 $buttons] {
- 0 exit
- 1 {save_project $Current(project).$P(file_suffix) 1; exit}
- }
- }
-
-
- # set the window and icon title
-
- proc set_title {name} {
- global P
- wm iconname . $name
- wm title . "$P(title) - $name"
- }
-